package com.zxc.controller.service;

import com.zxc.entity.SctService;
import com.zxc.service.SctServiceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping(value = "/feedbackservice")
public class FeedbackServiceController {

    @Autowired
    private SctServiceService sctServiceService;

    @RequestMapping("/{skipCount}/{pageSize}")
    @ResponseBody
    public Map<String,Object> getSctServiceListOrByCustName(@PathVariable Integer skipCount,
                                                            @PathVariable Integer pageSize){
        Map<String,Object> modelMap = new HashMap<>();
        int skipCounts = (skipCount-1)*pageSize;
        //根据服务状态，查询出已经已处理的服务
        String svrType = "已处理";
        List<SctService> sctServiceList  = sctServiceService.getSctServiceListBySvrStatus(skipCounts,pageSize,svrType);
        modelMap.put("dataList",sctServiceList);
        int total = sctServiceService.selectSctServiceCountByStatus(svrType);
        modelMap.put("total",total);
        return modelMap;
    }

    @RequestMapping(value = "/updateSctService")
    @ResponseBody
    public Map<String,Object> updateSctServiceById(SctService sctService){
        Map<String,Object> modelMap = new HashMap<>();
        System.out.println(sctService);
        sctService.setSvrStatus("已归档");
        int result = sctServiceService.updateDistributionById(sctService);
        if (result >0) {
            modelMap.put("success", true);
        }else{
            modelMap.put("success",false);
        }
        return modelMap;
    }

}
